
package flowchart.nodes;
import java.awt.*;
import java.awt.geom.*;

/**
 *
 * class representing GraphicsCircle
 */
public class GraphicsCircle extends AbstractGraphicsObject{

    private Ellipse2D r;


    public GraphicsCircle(float x, float y) {
            this.r = new Ellipse2D.Float(x, y, 80.0f, 80.0f);
    }

     public GraphicsCircle(String t,int x, int y) {
        this(x,y);
        setTitle(t);
        setZorder(10);
       }

    @Override
    public Rectangle getBounds() {
        return this.r.getBounds();
    }

       public void move(int x, int y) {
           r.setFrame(x, y, r.getWidth(), r.getHeight());
    }
       
    @Override
       public void setBounds(Rectangle rect) {
             r.setFrame(rect.x, rect.y, rect.width, rect.height);

    }

  public void draw(Graphics2D g) {

       FontMetrics fm = g.getFontMetrics();
       int h = fm.getAscent();
              int tw = fm.stringWidth(this.getTitle());

       Color old = g.getColor();
        g.setColor(bgColor);

    g.setColor(Color.white);
    g.fill(r);
    if (this.isSelected())
             g.setColor(Color.RED);
    else
    g.setColor(Color.BLACK);
    g.draw(r);

    Rectangle re = getBounds();
    g.drawString(getTitle(), (re.x+re.width/2)-(tw/2), re.y + (re.height/2));

    g.setColor(old);

    }

}
